package com.qf.util;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

public class ZkUtil {

    public static CuratorFramework getConn(){
        // 重试
        RetryPolicy retryPolicy = new ExponentialBackoffRetry(3000,2);
        // 创建连接对象
        CuratorFramework framework = CuratorFrameworkFactory
                .builder()
                .connectString("192.168.199.109:2181,192.168.199.109:2182,192.168.199.109:2183")
                .retryPolicy(retryPolicy)
                .build();
        // 开启连接
        framework.start();
        // 返回连接对象
        return framework;
    }

}
